package com.algo.jsyq;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import com.algo.dict.Dictionary;
import com.algo.dict.UDDictionary;


public class FindNewWords {

	public static List<String> getAllFiles(File dirOrFile){
		List<String> files = new ArrayList<String>();
		if(dirOrFile.isFile())
			files.add(dirOrFile.getAbsolutePath());
		else{
			for(File subPath : dirOrFile.listFiles())
				files.addAll(getAllFiles(subPath));
		}
		return files;
	}
	
	public static void main(String[] args) {
		List<String> files = getAllFiles(new File("C://Users//supertool//Documents//Tencent Files//419284651//FileRecv//dataCollection"));
		String[] path = (String[]) files.toArray(new String[files.size()]);
		System.out.println(path);
		
		/*if(new File("").exists())
			NagaoAlgorithm.applyNagao("D://过去的工作//江苏银行爬虫//zjgx.csv".split(","), "yuqing", "library/userLibrary/splitwords.utf8");
		
		String[] dictPath = {"D://过去的工作//江苏银行爬虫//sentiment//src//main//resources//dict//user_defined.dic",
				"D://过去的工作//江苏银行爬虫//sentiment//src//main//resources//dict//newwords_from_other_dic"};
		String out = "out";
		NewWords.findNewWords("yuqing", new UDDictionary(dictPath), out, "100,40".split(","));*/

		
	}
	/*public static void main(String[] args) throws IOException {
		String dir = "D://过去的工作//江苏银行爬虫//sentiment//src//main//resources//dict//";
		
		String[] wordsPath = {"positive_word.dic", "negative_word.dic", "not_word.dic", "degree_word.dic",
				"noise_word.dic", "question_word.dic"};
		
		Dictionary dict = new UDDictionary(dir + "user_defined.dic");
		BufferedWriter bw = new BufferedWriter(new FileWriter("new1"));
		for(String file : wordsPath){
			try {
				BufferedReader br = new BufferedReader(new FileReader(dir+file));
				String line;
				while((line = br.readLine()) != null){
					String word = line.split("[ \\t]")[0];
					if(word.contains("["))	continue;
					if(!dict.inDictionary(word))
						bw.write(word+"\tud\t100\n");
				}
				br.close();
			} catch (IOException e) {
				new RuntimeException(e);
			}
		}
		bw.close();

	}*/

}